﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Engine.Sgml.Schema;

namespace Engine.Sgml.Test.Util {
    class DElementGenerator {
        private DNameCollection nameCollection = new DNameCollection();

        public DElement Generate(DElementConfiguration configuration) {
            string value = string.Format("{0}_{1}", configuration.ElementName, configuration.ElementNumber++);
            DName name = nameCollection[value];
            if (name == null)
                name = nameCollection.Add(value);
            DElement element = new DElement(
                name,
                configuration.Occurrence
                );
            return element;
            }

        public DElement GenerateInclusion(DElementConfiguration configuration) {
            string value = string.Format("{0}_{1}", configuration.InclusionElementName, configuration.ElementNumber++);
            DName name = nameCollection[value];
            if (name == null)
                name = nameCollection.Add(value);
            DElement element = new DElement(
                name,
                DElementOccurrence.OnlyOnce
                );
            return element;
            }
        }
    }
